home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3958 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  45 lines

  1. Path: qns2.qns.com!not-for-mail
  2. From: mjarvis@qns2.qns.com (Michael Jarvis)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: EOF error
  5. Date: 31 Jan 1996 23:03:33 -0600
  6. Organization: Questar Network Services
  7. Message-ID: <4ephj5$74a@qns2.qns.com>
  8. References: <4eo12b$om3@newsbf02.news.aol.com>
  9. X-Newsreader: TIN [version 1.2 PL2]
  10.  
  11. Polver (Polver (polver@aol.com)) wrote:
  12. > Why doesn't the following work.
  13. > I'm using a unix system at school.
  14.  
  15. > #include <stdio.h>
  16.  
  17. > main()
  18. > {
  19. >     int c;
  20.  
  21. >     c = getchar();
  22. >     while (c != EOF) {
  23. >         putchar(c);
  24. >         c = getchar(c);
  25. Getchar doesn't take a parameter.  This should be c=getchar()
  26.  
  27. >     }
  28. > }
  29.  
  30. > I keep getting an error about EOF undefined ar not scalar or something.
  31.  
  32. I don't know what system you're using.  Other than the getchar(c) mistake
  33. this code should work.  According to secion 7.9.1 of the ANSI/ISO
  34. 9899-1990 C standard, the stdio.h file should define the EOF macro,
  35. "...which expands to a negative integral constant expression that is
  36. returned by several functions to indicate end-of-file, that is, no more
  37. input from a stream..."
  38.  
  39.                                               -michael
  40. -- 
  41. Michael Jarvis   |  Finger for PGP Public key  |   QNSnet Technical Support
  42. mjarvis@qns.com  | http://www.qns.com/~mjarvis |   Questar Network Services
  43. GC3.1: GCS d s+++: a26 C++++ USLV++++$ P++++ L++ E--- W++ N++ !o K+ W-- !O 
  44. M- !V PS+ PE Y+ PGP+ t+ 5 X R tv b+++ DI+++ D++ G+ e>++ h---(*) r+++ y+++
  45.